package org.ch02.test09;


import java.lang.reflect.Method;
import java.lang.reflect.Parameter;

/**
 * 获取方法原参数名称
 *
 * 配置参数：-parameters
 *
 * 1）IDEA配置：Build,Execution,Deployment -> Java Compiler -> Additional Command line parameters
 *
 * 2）Maven配置
 *
 *
 *
 * @author ZJL
 * @date 2025-03-25
 */
public class MainTest {

    public void sayHello(String name) {
        System.out.println("你好，" + name);
    }

    public static void main(String[] args) throws Exception {
        Method method = MainTest.class.getDeclaredMethod("sayHello", String.class);

        Parameter [] parameters = method.getParameters();
        String name = parameters[0].getName();
        System.out.println(name);
    }
}
